/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package calculadorfpa.connection;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author TECBMEPI
 */
public class DBUtils {

	public static Connection getConnection() throws Exception{

                String url = "jdbc:mysql://www.db4free.net/myfpa";
		String usuario = "myfpa";
                String senha = "myfpa123";
                
		Connection connection = null;
		try {
		    String driverName = "com.mysql.jdbc.Driver";
		    Class.forName(driverName);
		    connection = DriverManager.getConnection(url, usuario, senha);
		} catch (Exception e) {
		    e.printStackTrace();
		    throw new Exception("Não foi possível criar uma conexão para url:" + url + ", usuário:" + usuario + ", senha:" + senha);
		}
		return connection;
	}

        public static void main(String [] args) {
            try{
                DBUtils.getConnection().close();
            }catch(Exception e) {
                e.printStackTrace();
            }
        }

        
}
